﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using DataAccess.DataObject;
using DataAccess.BusinessObject;
using System.Globalization;
using System.Threading;
using System.Net.Configuration;

namespace EnmineKaitlin.admin
{
    public partial class order_details : Common.PageBase
    {
        int OrderID = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetParam();
                BindOrder();
            }
        }
        protected void GetParam(){
            if (Request.Params["o"] != null && Request.Params["o"].ToString() != "")
            {
                try
                {
                    OrderID = int.Parse(Request.Params["o"].ToString());
                }
                catch (Exception ex)
                {
                    OrderID = 0;
                }
            }
        }
        protected void BindOrder()
        {
            IList<OOrder> lstOrder = _BOrder.Get(OrderID);
            rptOrder.DataSource = lstOrder;
            rptOrder.DataBind();
        }
        protected IList<OCustomer> BindCustomer(int CustomerID)
        {
            BCustomer _BCustomer = new BCustomer();
            return _BCustomer.Get(CustomerID);
        }
        protected IList<OOrderDetails> BindOrderDetail(int OrderID)
        {
            BOrderDetails _BOrderDetail = new BOrderDetails();
            return _BOrderDetail.Get(OrderID);
        }

        protected void rptOrder_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Update")
            {
                int OrderID = int.Parse(e.CommandArgument.ToString());
                string Status = ((DropDownList)e.Item.FindControl("ddlStatus")).SelectedValue.ToString();
                _BOrder.Update(OrderID,Status);
                BindOrder();                
            }
        }
    }
}